﻿<!--#include file="../inc/easp/easp.asp"-->
<!--#include file="../inc/Conn1.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<% CheckLogin("../index.asp") 

    '权限不够直接跳到首页
	If Session("Authority")<>"0" Then
		Response.Write "<script type=""text/javascript"">top.location.href='../main.asp';</script>"
	end if				

dim yid,result
dim gid 

'删除时使用 action=del
IF request.QueryString("action")="del" Then
  
    yid=request.QueryString("yid")
    gid=request.QueryString("gid")
    if(yid<>"") then
        result = Easp.db.DeleteRecord("country", "y_id:" &yid) 
        
        result = Easp.db.DeleteRecord("GroupCountry", "GroupID=" &gid&" and CountryID=" &yid)       
        
        If result<>0 Then  
            Response.write("<Script language=JavaScript>alert('Delete Data Sucess!');</Script>") 
            
        else
            Response.write("<Script language=JavaScript>alert('Delete Data Fail!');</Script>") 
        End If  
        
        Response.Redirect "index.asp"
        
    End if
End if 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Holiday Control</title>
    <link rel="stylesheet" type="text/css" href="../css/theme.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />

    <script type="text/javascript">
    
	var StyleFile = "theme" + document.cookie.charAt(6) + ".css";
	document.writeln('<link rel="stylesheet" type="text/css" href="../css/' + StyleFile + '">');
	
	
    function chkv(obj)
    { 
        //document.getElementById('stext').value=obj.options[obj.selectedIndex].text 
        //alert("index.asp?gid="+obj.options[obj.selectedIndex].value);
        location.href="index.asp?selectedIndex="+obj.options[obj.selectedIndex].value;
        
    } 
    
    function Rrederict()
    { 
        //var addgroup="AddGroup.asp?id=";
        //addgroup=addgroup+obj.options[obj.selectedIndex].text 
        //top.location.href=addgroup;
        top.location.href="Group.asp";
    } 
    
    function Add()
    { 
        //var addgroup="AddGroup.asp?id=";
        //addgroup=addgroup+obj.options[obj.selectedIndex].text 
        //top.location.href=addgroup;
    
       // var obj=document.getElementById("group");

        top.location.href='addCountry.asp';
    } 
    
  function Edit( yid1, countryname1,holidays1,gid1)
   { 
      //alert("dd");
        var yid=yid1;
        var countryname=countryname1;
        var gid=gid1;
        var holidays=holidays1;
        //alert('EditCountry.asp?action=edit&yid='+yid+"&countryname="+countryname+"&selectedIndex="+gid+"&holidays="+holidays);
        top.location.href='EditCountry.asp?action=edit&yid='+yid+"&countryname="+countryname+"&selectedIndex="+gid+"&holidays="+holidays;
        
    } 
    
    function Delete( yid,gid)
   { 
      if(confirm("Are you sure?"))
		  {     

        top.location.href='index.asp?action=del&yid='+yid+"&gid="+gid;
      }
      else {}
    } 
    
    </script>

    <!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
</head>
<body>
    <div id="container">
        <div id="header">
            <div id="divAccount" style="float: right;">
                <a href="../user/account.asp" style="color: white">Account</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="../inc/logout.asp" style="color: white">Logout</a>
            </div>
            <h2>
                Country Control</h2>
            <div id="topmenu">
                <ul>
                    <li><a href="../main.asp">Home</a></li>
                    <li class="current"><a href="#">Country</a></li>
                    <li><a href="../Holiday/index.asp">Holiday</a></li>
                    <li><a href="../Times/index.asp">Times</a></li>
                    <li><a href="../wallboard/index.asp">WallBoard</a></li>
                    <%
				   If Session("Authority")="0" Then 
				       Response.Write("<li><a href='../user/index.asp'>User</a></li>")
				   End if
                    %>
                    <li>
                        <% If Session("Passed")=true Then %>
                        <a href="../inc/logout.asp">Logout</a><% End If %></li>
                </ul>
            </div>
        </div>
        <div id="top-panel">
            <div id="panel">
                <ul>
                    <% 
				  If Session("Authority")="0" Then
				  	Easp.wc "<li><a href='addcountry.asp' class='add'>Add Country</a></li>"
				    Easp.wc "<li><a href='Group.asp' class='shipping'>Goto Group</a></li>"				    
				  end if
                    %>
                </ul>
            </div>
        </div>
        <div id="wrapper">
            <div id="content">
                <form name="myform" action="index.asp" method="post">
                    <div id="box">
                        <div id="rightnow">
				                  <h3 class="reallynow"> 
					                  <span>Country</span>			
					                  <a href="Group.asp" class="shipping">Goto Group</a>		    
					                  <a href="addCountry.asp" class="add">Add Country</a> 					                  
					                  <br />
				                  </h3>				
			                  </div>
                      
                        
                       <!-- <table width="100%" style="text-align: center;">-->
                            <p>
                         
                                <%
                                dim rscountry
                                dim epage
                                dim i
                                dim uid
                                dim count
                                
                                count=0
                                If Session("ID")<>"" then
                                    uid=Session("ID")
                                end if
                                
                                'Response.write("<Script language=JavaScript>alert('"&Session("Authority")&"');</Script>") 
                                
                               'if Session("Authority")<>"0" then
                                    'If Session("ID")<>"" then
                                         'set rscountry = Easp.db.GetRecordBySQL("SELECT Country.y_id, Country.CountryName FROM Country,UserCountry where Country.g_id = UserCountry.CountryID and UserCountry.UserID="&uid)  
                             
                                   ' end if
                                          set rscountry = Easp.db.GetRecordBySQL("SELECT Country.y_id, Country.CountryName,Group.GroupName, Country.HolidayNum,Country.g_id FROM Country INNER JOIN [Group] ON Country.g_id = Group.ID ORDER BY Country.y_id")  
                                
                               'else
                                    
                                    
                                    
                               ' end if
        
                                If Not Easp.IsN(rscountry) Then
                                    rscountry.pagesize=20
                                    
                                    if request("page")<>"" then
                                       epage=cint(request("page"))
                                       if epage<1 then
                                            epage=1 
                                        end if
                                       if epage>rscountry.pagecount then 
                                            epage=rscountry.pagecount
                                        end if
                                    else
                                        epage=1
                                    end if
                                    rscountry.absolutepage=epage
                                end if
                                %>
                                   
                               <table border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" width="80%" align="center">
                                    <tr bgcolor="#FFFFFF" align="center">
                                        <%
                                          if Not Easp.IsN(rscountry) Then
                                        %>
                                            <th>Code</th>
                                            <th>Country</th>
                                            <th>Group</th>
                                            <th>Holiday Numbers</th>
                                            <th>Delete</th>
                                            <th>Edit</th>
                                            <th>Details</th>
                                        <%end if %>
                                    </tr>
                                     <%
                                      if Not Easp.IsN(rscountry) Then
                                        for i=0 to rscountry.pagesize-1
                                        if rscountry.bof or rscountry.eof then exit for
                                        count=count+1
                                    %>
                                        <tr bgcolor="#FFFFFF" align="center">
                                            <td><%=count%></td>
                                            <td><%=rscountry(1).value%></td>
                                            <td><%=rscountry(2).value%></td>
                                            <td><%=rscountry(3).value%></td>
                                            <td>
                                            <a href="javascript:Delete('<%=rscountry(0).value%>','<%=rscountry(3).value %>')">Delete</a>
                                            </td>
                                            <td><a href="javascript:Edit('<%=rscountry(0).value%>','<%=rscountry(1).value%>','<%=rscountry(3).value%>','<%=rscountry(4).value%>')">Edit</a> </td>
                                            <!--<td>
                                                <a href="EditGroup.asp?action=edit&yid=<%=rscountry(0).value%> &countryname=<%=rscountry(1).value%>&holidays=<%=rscountry(3).value%>&gid=<%=rscountry(4).value%>">Edit</a>
                                            </td>-->
                                            <td><a href="Province.asp?action=det&yid=<%=rscountry(0).value%>">Details</a></td>
                                        </tr>
                                    <%
                                        rscountry.movenext()
                                        next
                                        end if
                                    %>
                                </table>
                                
                                
                                <%
                                
                                if Not Easp.IsN(rscountry) Then
                                    Easp.w "<p align='center'>"
                                    
                                    Easp.w "<a href='index.asp'>First</a> <a href='index.asp?page="&epage-1&"'>Previous</a>"
                                    Easp.w "<a href='index.asp'>Next</a> <a href='index.asp?page="&epage-1&"'>Last</a>"
                                   
                                    'Easp.w "<a href='index.asp?page="%epage+1&"'>Next</a>&nbsp; <a href='index.asp?page="&rscountry.pagecount&"'>Last</a>"
                                    Easp.w "</p>"
                                    
                                    Easp.w "<p align='center'>"
                                    Easp.w "Now at"
                                    Easp.w epage
                                    Easp.w "page ,Totle"
                                    Easp.w rscountry.pagecount
                                    Easp.w "page"
                                    Easp.w "</p>"
      
                                    Easp.db.C(rscountry) 
                                 else 
                                 
                                    Easp.w "<h4> Has no data!</h4>"
                                 end if
                                  
                                %>   
                                     
                            </p>
                       <!-- </table>-->
                        <div id="pager">
                        <br/>
                            <%
					                    If Session("Authority")="0" Then
					                     'Easp.wc "<input name='add' type='button' class='btn' value='add' onclick=""top.location.href='add.asp?page=country';""/>"
					                     'Easp.wc "<input name='add' type='button' class='btn' value='add' onclick='Add()'/>"
						                  End if
                            %>
                           <br/>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!--#include file="../inc/footer.asp" -->
    </div>
</body>
</html>
